package cn.jiguang.demo.baselibrary;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import androidx.core.content.ContextCompat;

import com.hjq.toast.ToastUtils;
import android.os.Handler;
import android.os.Looper;
import cn.jiguang.demo.R;


public class ToastHelper {
    public static final Handler mHandler = new Handler(Looper.getMainLooper());
    private ToastHelper() {
    }


    public static void showOk(Context context, String s) {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                View v = LayoutInflater.from(context).inflate(R.layout.d_toast_customs, null);
                ImageView imageView = v.findViewById(R.id.iv_icon);
                imageView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.d_ic_toast_ok));
                ToastUtils.setView(v);
                ToastUtils.setGravity(Gravity.CENTER, 0, 0);
                ToastUtils.show(s);
            }
        });

    }

    public static void showOther(Context context, String s) {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                View v = LayoutInflater.from(context).inflate(R.layout.d_toast_customs, null);
                ImageView imageView = v.findViewById(R.id.iv_icon);
                imageView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.d_ic_toast_other));
                ToastUtils.setView(v);
                ToastUtils.setGravity(Gravity.CENTER, 0, 0);
                ToastUtils.show(s);
            }
        });

    }
}
